<div class="doc-item" id="doc-931"><h2 class="doc-item-name">insert-values<span class="namespace">(clojure.contrib.sql)</span></h2><ul class="var-arglists"><li>(<span class="var-name">insert-values</span> table column-names &amp; value-groups)</li></ul><div class="var-docstring"><p>Inserts rows into a table with values for specified columns only.
  column-names is a vector of strings or keywords identifying columns. Each
  value-group is a vector containing a values for each column in
  order. When inserting complete rows (all columns), consider using
  insert-rows instead.</p></div><div class="var-source"><pre>; clojure/contrib/sql.clj:124
(defn insert-values
  [table column-names &amp; value-groups]
  (let [column-strs (map as-str column-names)
        n (count (first value-groups))
        template (apply str (interpose &quot;,&quot; (replicate n &quot;?&quot;)))
        columns (if (seq column-names)
                  (format &quot;(%s)&quot; (apply str (interpose &quot;,&quot; column-strs)))
                  &quot;&quot;)]
    (apply do-prepared
           (format &quot;INSERT INTO %s %s VALUES (%s)&quot;
                   (as-str table) columns template)
           value-groups)))</pre></div><div class="license"><p>Copyright (c) Rich Hickey. All rights reserved.</p><p>The use and distribution terms for this software are covered by the <a href="http://opensource.org/licenses/eclipse-1.0.php">Eclipse Public License 1.0</a>, which can be found in the file
          epl-v10.html at the root of this distribution. By using this software
          in any fashion, you are agreeing to be bound by the terms of this
          license. You must not remove this notice, or any other, from this
          software.</p></div></div>